<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE topic
  PUBLIC "-//OASIS//DTD DITA Composite//EN" "ditabase.dtd">
<topic id="topic1" xml:lang="en">
  <title id="hg141670">pg_proc</title>
  <body>
    <p>The <codeph>pg_proc</codeph> system catalog table stores information about functions (or
      procedures), both built-in functions and those defined by <codeph>CREATE FUNCTION</codeph>.
      The table contains data for aggregate and window functions as well as plain functions. If
        <codeph>proisagg</codeph> is true, there should be a matching row in
        <codeph>pg_aggregate</codeph>.</p>
    <p>For compiled functions, both built-in and dynamically loaded, <codeph>prosrc</codeph>
      contains the function's C-language name (link symbol). For all other currently-known language
      types, <codeph>prosrc</codeph> contains the function's source text. <codeph>probin</codeph> is
      unused except for dynamically-loaded C functions, for which it gives the name of the shared
      library file containing the function.</p>
    <table id="hg150092">
      <title>pg_catalog.pg_proc</title>
      <tgroup cols="4">
        <colspec colnum="1" colname="col1" colwidth="131pt"/>
        <colspec colnum="2" colname="col2" colwidth="69pt"/>
        <colspec colnum="3" colname="col3" colwidth="104.25pt"/>
        <colspec colnum="4" colname="col4" colwidth="147pt"/>
        <thead>
          <row>
            <entry colname="col1">column</entry>
            <entry colname="col2">type</entry>
            <entry colname="col3">references</entry>
            <entry colname="col4">description</entry>
          </row>
        </thead>
        <tbody>
          <row>
            <entry colname="col1">
              <codeph>oid</codeph>
            </entry>
            <entry colname="col2">oid</entry>
            <entry colname="col3"/>
            <entry colname="col4">Row identifier (hidden attribute; ust be explicitly selected)</entry>
          </row>
          <row>
            <entry colname="col1">
              <codeph>proname</codeph>
            </entry>
            <entry colname="col2">name</entry>
            <entry colname="col3"/>
            <entry colname="col4">Name of the function</entry>
          </row>
          <row>
            <entry colname="col1">
              <codeph>pronamespace</codeph>
            </entry>
            <entry colname="col2">oid</entry>
            <entry colname="col3">pg_namespace.oid</entry>
            <entry colname="col4">The OID of the namespace that contains this function</entry>
          </row>
          <row>
            <entry colname="col1">
              <codeph>proowner</codeph>
            </entry>
            <entry colname="col2">oid</entry>
            <entry colname="col3">pg_authid.oid</entry>
            <entry colname="col4">Owner of the function</entry>
          </row>
          <row>
            <entry colname="col1">
              <codeph>prolang</codeph>
            </entry>
            <entry colname="col2">oid</entry>
            <entry colname="col3">pg_language.oid</entry>
            <entry colname="col4">Implementation language or call interface of this
              function</entry>
          </row>
          <row>
            <entry colname="col1">
              <codeph>procost</codeph>
            </entry>
            <entry colname="col2">float4</entry>
            <entry colname="col3"/>
            <entry colname="col4">Estimated execution cost (in cpu_operator_cost units); if
              <codeph>proretset</codeph> is <codeph>true</codeph>, identifies the cost per row returned</entry>
          </row>
          <row>
            <entry colname="col1">
              <codeph>prorows</codeph>
            </entry>
            <entry colname="col2">float4</entry>
            <entry colname="col3"/>
            <entry colname="col4">Estimated number of result rows (zero if not <codeph>proretset</codeph>)</entry>
          </row>
          <row>
            <entry colname="col1">
              <codeph>provariadic</codeph>
            </entry>
            <entry colname="col2">oid</entry>
            <entry colname="col3">pg_type.oid</entry>
            <entry colname="col4">Data type of the variadic array parameter's elements, or zero if
              the function does not have a variadic parameter</entry>
          </row>
          <row>
            <entry colname="col1">
              <codeph>protransform</codeph>
            </entry>
            <entry colname="col2">regproc</entry>
            <entry colname="col3">pg_proc.oid</entry>
            <entry colname="col4">Calls to this function can be simplified by this other function</entry>
          </row>
          <row>
            <entry colname="col1">
              <codeph>proisagg</codeph>
            </entry>
            <entry colname="col2">boolean</entry>
            <entry colname="col3"/>
            <entry colname="col4">Function is an aggregate function</entry>
          </row>
          <row>
            <entry colname="col1">
              <codeph>proiswindow</codeph>
            </entry>
            <entry colname="col2">boolean</entry>
            <entry colname="col3"/>
            <entry colname="col4">Function is a window function</entry>
          </row>
          <row>
            <entry colname="col1">
              <codeph>prosecdef</codeph>
            </entry>
            <entry colname="col2">boolean</entry>
            <entry colname="col3"/>
            <entry colname="col4">Function is a security definer (for example, a 'setuid'
              function)</entry>
          </row>
          <row>
            <entry colname="col1">
              <codeph>proleakproof</codeph>
            </entry>
            <entry colname="col2">boolean</entry>
            <entry colname="col3"/>
            <entry colname="col4">The function has no side effects. No information about the arguments
              is conveyed except via the return value. Any function that might throw an error
              depending on the values of its arguments is not leak-proof.</entry>
          </row>
          <row>
            <entry colname="col1">
              <codeph>proisstrict</codeph>
            </entry>
            <entry colname="col2">boolean</entry>
            <entry colname="col3"/>
            <entry colname="col4">Function returns NULL if any call argument is NULL. In that case
              the function will not actually be called at all. Functions that are not strict must be
              prepared to handle NULL inputs.</entry>
          </row>
          <row>
            <entry colname="col1">
              <codeph>proretset</codeph>
            </entry>
            <entry colname="col2">boolean</entry>
            <entry colname="col3"/>
            <entry colname="col4">Function returns a set (multiple values of the specified data
              type)</entry>
          </row>
          <row>
            <entry colname="col1">
              <codeph>provolatile</codeph>
            </entry>
            <entry colname="col2">char</entry>
            <entry colname="col3"/>
            <entry colname="col4">Tells whether the function's result depends only on its input
              arguments, or is affected by outside factors. <codeph>i</codeph> = <i>immutable</i>
              (always delivers the same result for the same inputs), <codeph>s</codeph> =
                <i>stable</i> (results (for fixed inputs) do not change within a scan), or
                <codeph>v</codeph> = <i>volatile</i> (results may change at any time or functions
              with side-effects). </entry>
          </row>
          <row>
            <entry colname="col1">
              <codeph>pronargs</codeph>
            </entry>
            <entry colname="col2">int2</entry>
            <entry colname="col3"/>
            <entry colname="col4">Number of arguments</entry>
          </row>
          <row>
            <entry colname="col1">
              <codeph>pronargdefaults</codeph>
            </entry>
            <entry colname="col2">int2</entry>
            <entry colname="col3"/>
            <entry colname="col4">Number of arguments that have default values</entry>
          </row>
          <row>
            <entry colname="col1">
              <codeph>prorettype</codeph>
            </entry>
            <entry colname="col2">oid</entry>
            <entry colname="col3">pg_type.oid</entry>
            <entry colname="col4">Data type of the return value</entry>
          </row>
          <row>
            <entry colname="col1">
              <codeph>proargtypes</codeph>
            </entry>
            <entry colname="col2">oidvector</entry>
            <entry colname="col3">pg_type.oid</entry>
            <entry colname="col4">An array with the data types of the function arguments. This
              includes only input arguments (including <codeph>INOUT</codeph> and
                <codeph>VARIADIC</codeph> arguments), and thus represents the call signature of the
              function.</entry>
          </row>
          <row>
            <entry colname="col1">
              <codeph>proallargtypes</codeph>
            </entry>
            <entry colname="col2">oid[]</entry>
            <entry colname="col3">pg_type.oid</entry>
            <entry colname="col4">An array with the data types of the function arguments. This
              includes all arguments (including <codeph>OUT</codeph> and <codeph>INOUT</codeph>
              arguments); however, if all of the arguments are <codeph>IN</codeph> arguments, this
              field will be null. Note that subscripting is 1-based, whereas for historical reasons
              <codeph>proargtypes</codeph> is subscripted from 0.</entry>
          </row>
          <row>
            <entry colname="col1">
              <codeph>proargmodes</codeph>
            </entry>
            <entry colname="col2">char[]</entry>
            <entry colname="col3"/>
            <entry colname="col4">An array with the modes of the function arguments:
                <codeph>i</codeph> = <codeph>IN</codeph>, <codeph>o</codeph> = <codeph>OUT</codeph>
              , <codeph>b</codeph> = <codeph>INOUT</codeph>, <codeph>v</codeph> =
                <codeph>VARIADIC</codeph>. If all the arguments are IN arguments, this field will be
              null. Note that subscripts correspond to positions of <codeph>proallargtypes</codeph>,
              not <codeph>proargtypes</codeph>.</entry>
          </row>
          <row>
            <entry colname="col1">
              <codeph>proargnames</codeph>
            </entry>
            <entry colname="col2"> text[] </entry>
            <entry colname="col3"/>
            <entry colname="col4">An array with the names of the function arguments. Arguments
              without a name are set to empty strings in the array. If none of the arguments have a
              name, this field will be null. Note that subscripts correspond to positions of
              <codeph>proallargtypes</codeph> not <codeph>proargtypes</codeph>.</entry>
          </row>
          <row>
            <entry colname="col1">
              <codeph>proargdefaults</codeph>
            </entry>
            <entry colname="col2">pg_node_tree</entry>
            <entry colname="col3"/>
            <entry colname="col4">Expression trees (in <codeph>nodeToString()</codeph> representation) for default argument values. This is a list with
              <codeph>pronargdefaults</codeph> elements, corresponding to the last <varname>N</varname> input
              arguments (i.e., the last <varname>N</varname> <codeph>proargtypes</codeph> positions). If none of the
              arguments have defaults, this field will be null.</entry>
          </row>
          <row>
            <entry colname="col1">
              <codeph>prosrc </codeph>
            </entry>
            <entry colname="col2">text</entry>
            <entry colname="col3"/>
            <entry colname="col4">This tells the function handler how to invoke the function. It
              might be the actual source code of the function for interpreted languages, a link
              symbol, a file name, or just about anything else, depending on the implementation
              language/call convention.</entry>
          </row>
          <row>
            <entry colname="col1">
              <codeph>probin</codeph>
            </entry>
            <entry colname="col2">text</entry>
            <entry colname="col3"/>
            <entry colname="col4">Additional information about how to invoke the function. Again,
              the interpretation is language-specific.</entry>
          </row>
          <row>
            <entry colname="col1"><codeph>proconfig</codeph></entry>
            <entry colname="col2">text[]</entry>
            <entry colname="col3"/>
            <entry colname="col4">Function's local settings for run-time configuration variables.</entry>
          </row>
          <row>
            <entry colname="col1">
              <codeph>proacl</codeph>
            </entry>
            <entry colname="col2">aclitem[]</entry>
            <entry colname="col3"/>
            <entry colname="col4">Access privileges for the function as given by
                <codeph>GRANT</codeph>/<codeph>REVOKE</codeph></entry>
          </row>
          <row>
            <entry colname="col1"><codeph>prodataaccess</codeph></entry>
            <entry colname="col2">char</entry>
            <entry colname="col3"/>
            <entry colname="col4">Provides a hint regarding the type SQL statements that are
              included in the function: <codeph>n</codeph> - does not contain SQL,
                <codeph>c</codeph> - contains SQL, <codeph>r</codeph> - contains SQL that reads
              data, <codeph>m</codeph> - contains SQL that modifies data</entry>
          </row>
          <row>
            <entry colname="col1"><codeph>proexeclocation</codeph></entry>
            <entry colname="col2">char</entry>
            <entry colname="col3"/>
            <entry colname="col4">Where the function runs when it is invoked: <codeph>m</codeph>
              - master only, <codeph>a</codeph> - any segment instance, <codeph>s</codeph> - all
              segment instances, <codeph>i</codeph> - initplan.</entry>
          </row>
        </tbody>
      </tgroup>
    </table>
  </body>
</topic>
